package com.wk1un2.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wk1un2.service.ShoppingCartService;
import com.wk1un2.util.Result;

@Controller
public class ShoppingCartController {
	@Autowired
	ShoppingCartService service;

	@RequestMapping("/Backstage/getAllShoppingCart")
	@ResponseBody
	public Object getAll(@RequestParam("page") int page, @RequestParam("limit") int limit,
			@RequestParam("u_id") String u_id) {
		Integer id = null;
		if (u_id != null && u_id != "") {
			id = Integer.parseInt(u_id);
		}
		List<Map<String, Object>> ls = service.getAll((page - 1) * limit, limit, id,null);
		Result res = new Result(0, "", service.count(), ls);
		return res;
	}
}
